/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package volcarobjetos;

import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.Date;

/**
 *
 * @author User
 */
public class VolcarObjetos {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws ClassNotFoundException {
      ArrayList <Figura> Figura =new ArrayList();
       File f=new File("figuras.bin");
      
      Triangulo t = new Triangulo(4, 3,"rojo");
      Rectangulo r = new Rectangulo (5, 6, "amarillo");
      Circulo c = new Circulo (4 , "verde");
      
      Figura.add(c);
      Figura.add(t);
      Figura.add(r);
      
       VolcarFichero(f, Figura);
      }
    public static void VolcarFichero(File f, ArrayList<Figura> Figura ) throws ClassNotFoundException{
        
         ObjectOutputStream out=null;
        try {
            out=new ObjectOutputStream(new FileOutputStream(f));
           
            for(Figura fig:Figura){
                out.writeObject(fig);
            }
        }
        catch (EOFException ex){
            
        }
        catch (IOException ex) {
            System.out.println("Error en la lectura/escritura");
        }
    }
           public static void LeerFichero(File f, ArrayList <Figura> Figura {
        
         ObjectInputStream in=null;
         
          while(true)
                 
        try {
            in=new ObjectInputStream(new FileInpuStream(f));
          
            
        }
        catch (EOFException ex){
            
        }
        catch (IOException ex) {
            System.out.println("Error en la lectura/escritura");
              
            
        }  
       }
}
           

